package advanced.design_mode.factorymode;

import java.lang.reflect.InvocationTargetException;

/**
 * car 的工厂类
 * <p>
 * 该案例是一个抽象工厂方法
 */
public class CarFactory {

    public static Car create(Class clz) {
        Object obj = null;
        try {
            obj = clz.getConstructor().newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
        return (Car) obj;
    }


}

